package org.ruslan.kolobok.model;

public class AliveType extends Type {
	private float speed;
	private String behaviour;
	private Behaviour behaviourImpl;
	
	public float getSpeed() {
		return speed;
	}

	@Override
	public String toString() {
		StringBuilder builder = new StringBuilder();
		builder.append(super.toString());
		builder.append("AliveType [speed=");
		builder.append(speed);
		builder.append(", behaviour=");
		builder.append(behaviour);
		builder.append("]");
		return builder.toString();
	}

	public Behaviour getBehaviour() {
		if (behaviourImpl == null) {
			try {
				behaviourImpl = (Behaviour) Class.forName(behaviour).newInstance();
			} catch (InstantiationException e) {
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			}
		}
		
		return behaviourImpl;
	}

}